package me.zhenqu.web.util;

import me.zhenqu.model.pojo.entity.User;
import javax.servlet.http.HttpSession;

/**
 * Created by IntelliJ IDEA.
 * User: yibing.tan
 * Date: 11-11-17
 * Time: 下午1:22
 * To change this template use File | Settings | File Templates.
 */
public final class SessionUtil {
    private static final String USER_TAG = "user";
    public static User loadUser(HttpSession session){
        return ((User) session.getAttribute(USER_TAG));
    }

    public static void setUser(HttpSession session, User user){
        if (user!=null)
            session.setAttribute(USER_TAG, user);
    }

    public static void removeUser(HttpSession session){
        session.removeAttribute(USER_TAG);
    }
}
